package Example1;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/1login")
public class loginServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        resp.setContentType("text/html");
        if (username.equals("tom")){
            resp.sendRedirect("index.html");
        }
        System.out.println("username: "+ username);
        System.out.println("password: "+ password);
        resp.getWriter().write("username: "+ username +"<br>"+  "password: "+ password);
    }

}
